<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
<h1>BMI测试页面</h1>
<input type="text" v-model="height" placeholder="身高">
<input type="text" v-model="weight" placeholder="体重">
<input type="button" value="提交" @click="f1()">
<h2>{{"结果:"+result}}</h2>
</div>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
    let v = new Vue({
        el:"body>div",
        data:{
            height:"",
            weight:"",
            result:""
        },
        methods:{
            f1(){
                axios.get("/bmi?height="+v.height+"&weight="+v.weight).then(function (response) {
                    //response代表响应对象,里面装着服务器响应的数据
                    //response.data服务器响应的数据
                    v.result=response.data;
                    alert(response.data);
                })
            }
        }
    })
</script>

</body>
</html>